package com.loong.pojo;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 数据库对应的购物车表
 */
public class Cart implements Serializable {
    private static final long serialVersionUID = 1L;
    private Integer cid;
    private Integer uid;
    private Integer pid;
    private Product product;
    private Integer cnum = 0;//购物车数量
    private BigDecimal cprice;// 商品小计

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    public Integer getCid() {
        return cid;
    }

    public void setCid(Integer cid) {
        this.cid = cid;
    }

    public Integer getUid() {
        return uid;
    }

    public void setUid(Integer uid) {
        this.uid = uid;
    }

    public Integer getPid() {
        return pid;
    }

    public void setPid(Integer pid) {
        this.pid = pid;
    }

    public Integer getCnum() {
        return cnum;
    }

    public void setCnum(Integer cnum) {
        this.cnum = cnum;
    }

    public BigDecimal getCprice() {
        BigDecimal pprice = product.getPprice();
        BigDecimal bigDecimal = new BigDecimal(cnum);
        return pprice.multiply(bigDecimal);
    }

    public void setCprice(BigDecimal cprice) {
        this.cprice = cprice;
    }

    @Override
    public String toString() {
        return "Cart{" +
                "cid=" + cid +
                ", uid=" + uid +
                ", pid=" + pid +
                ", product=" + product +
                ", cnum=" + cnum +
                ", cprice=" + cprice +
                '}';
    }
}
